#include <cstdio>

using namespace std;

#define N 1001

int tree[N];

int find_root(int x);

int main(int argc, char const* argv[]) {
    int n, m;
    while (scanf("%d %d", &n, &m) != EOF) {
        for (int i = 1; i <= n; ++i)
            tree[i] = -1;
        for (int i = 0; i < m; ++i) {
            int a, b;
            scanf("%d%d", &a, &b);
            a = find_root(a);
            b = find_root(b);
            if (a != b)
                tree[a] = b;
        }
        int result = 0;
        for (int i = 1; i <= n; ++i) {
            if (tree[i] == -1)
                result++;
        }
        if (result == 1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

int find_root(int x) {
    if (tree[x] == -1)
        return x;
    else {
        int temp_index = find_root(tree[x]);
        tree[x] = temp_index;
        return temp_index;
    }
}